// 8_5 Classes and inheritance.cpp : Defines the entry point for the console application.
//编写一个程序，其中有一个汽车类Vehicle，它具有一个需要传递参数的构造函数，类中的数据成员：
//车轮个数wheels和车重weight为保护属性；小车类Car是它的私有派生类，其中包含载人数passager_load；
//卡车类Truck是Vehicle的私有派生类，其中包含载人数passager_load和载重量payload。每个类都有相关数据的输出方法。

#include "stdafx.h"
#include<iostream>

using namespace std;

class Vehicle
{
protected:
	int wheels;
	double weight;
	void get(int a,double b);
};

class Car : public Vehicle
{
public:
	void get(int a,double b,int c);
	void set(void)
	{
		cout<<"The weight of this car is "<<weight<<" tons,the number of wheels is "<<wheels<<" and the passager_load is "<< passager_load<<endl;
	}
	
private:
	int passager_load;
};

void Car::get(int a,double b,int c)
{
	wheels=a;
	weight=b;
	passager_load=c;
}

class Truck : public Vehicle
{
public:
	void get(int a,double b,int c,double d)
	{
	    wheels=a;
	    weight=b;
	    passager_load=c;
	    payload=d;
	}
	
	void set(void)
	{
		cout <<"The weight of this truck is "<<weight<<
		       " tons,the number of wheels is "<<wheels<<
		       ",the passager_load is "<< passager_load<<
		       " and the payload is "<<payload<<" tons"<<endl;
	}
	
private:
	int passager_load;
	int payload;
};

void main()
{
	Car baoma;
	Truck dongfeng;
//	Vehicle de;	
	baoma.get(4,2,4);//wheels,weight,passager_load
	baoma.set();
	dongfeng.get(4,4,2,20);//wheels,weight,passager_load,payload
	dongfeng.set();
}

